﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.BlackApart.Business.Apartments;
using blackhouse.BlackApart.Business.ApartmentServices;

namespace blackhouse.BlackApart.Business.Reservations {
    public struct VariantItem {

        public IApartment Apartment;
        public DateTime ArrivalDate;
        public DateTime DepartureDate;
        public int NumberOfPeoples;
        public IAdditionalService ExtraBedService;

        #region Overrides For Identification

        public override bool Equals(object other) {
            return other is VariantItem && this.Equals((VariantItem) other);
        }

        private bool Equals(VariantItem obj) {
            return
                this.Apartment.Id == obj.Apartment.Id
                && this.ArrivalDate.Date == obj.ArrivalDate.Date
                && this.DepartureDate.Date == obj.DepartureDate.Date
                && this.NumberOfPeoples == obj.NumberOfPeoples;
        }

        public override int GetHashCode() {
            return Convert.ToInt32(this.Apartment.Id + ( this.ArrivalDate - new DateTime(2010, 1, 1) ).TotalHours + ( this.ArrivalDate - new DateTime(2010, 1, 1) ).TotalHours + this.NumberOfPeoples);
        }

        public static bool operator ==(VariantItem lhs, VariantItem rhs) {
            return lhs.Equals(rhs);
        }

        public static bool operator !=(VariantItem lhs, VariantItem rhs) {
            return !lhs.Equals(rhs);
        }

        #endregion

    }
}
